package com.shu.proxcy.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @author ssm
 * @version V1.0
 * @description:
 * @date 2019/3/8 20:07
 */

public class Meipo implements InvocationHandler {

    private Person person;

    public Object getInstance(Person person) throws Exception {
        this.person = person;
        Class clazz = person.getClass();
        return Proxy.newProxyInstance(clazz.getClassLoader(), clazz.getInterfaces(), this);
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("--start---------------");
        this.person.findLove();
        System.out.println("--end---------------");
        return null;
    }
}
